-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reverts entity data without locking for better performance #1452
base: master
Are you sure you want to change the base?
Conversation
@coderabbitai full review please |
@shubham1g5: I will perform a full review of the PR. ✅ Actions performedFull review triggered. |
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
src/main/java/org/commcare/cases/entity/AsyncEntity.java (1)
138-138
: Document the locking strategyThe class uses a complex locking strategy with both database-level locks and object-level synchronization. While there's a comment about lock ordering, it would be valuable to add comprehensive documentation about:
- The exact order of lock acquisition
- Why this order prevents deadlocks
- Which operations require which locks
Add a class-level documentation block like:
/** * Threading Model: * This class uses two levels of locking: * 1. Database-level locking (via EntityStorageCache) * 2. Object-level locking (via mAsyncLock) * * Lock Ordering: * To prevent deadlocks, locks must be acquired in the following order: * 1. First acquire the database lock (via lockCache()) * 2. Then acquire the object lock (via synchronized(mAsyncLock)) * * Operations requiring both locks: * - Writing to the cache * - Reading from the cache when value isn't in memory * * Operations requiring only object lock: * - Reading/writing in-memory values */
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/main/java/org/commcare/cases/entity/AsyncEntity.java
(1 hunks)
🔇 Additional comments (1)
src/main/java/org/commcare/cases/entity/AsyncEntity.java (1)
Line range hint 138-179
: Verify performance impact of lock changes
While the changes aim to improve performance by avoiding unnecessary locks, we should verify the actual impact on loading times, especially for the mentioned case of 10,000 entries.
Run the following script to analyze lock-related patterns in the codebase:
…improve performance
eea08fa
to
ea93ab7
Compare
Technical Summary
Return entity data if available without extra overhead caused by aquiring a db lock.
Safety Assurance
Safety story
I can't imagine us needing a db lock just to return a set variable which is all this PR does.
Automated test coverage
NA
QA Plan
None
Special deploy instructions
Rollback instructions
Review
Duplicate PR
Automatically duplicate this PR as defined in contributing.md.
Summary by CodeRabbit
New Features
Bug Fixes